import java.awt.image.ColorModel;
import java.awt.image.ImageConsumer;
import java.util.Hashtable;


public class MyConsumer implements ImageConsumer {
	public boolean ready = false;
	public int width, height;
	public int[] image = null;
	
	@Override
	public void imageComplete(int arg0) {
		ready = true;
	}

	@Override
	public void setColorModel(ColorModel arg0) {
	}

	@Override
	public void setDimensions(int w, int h) {
		width = w;
		height = h;
		image = new int[w * h];
	}

	@Override
	public void setHints(int arg0) {
	}

	@Override
	public void setPixels(int x, int y, int w, int h, ColorModel cm, byte[] data, int offset, int size) {
	}

	@Override
	public void setPixels(int x, int y, int w, int h, ColorModel cm, int[] data, int offset, int size) {
		for(int a = 0; a < w; a++) for(int b = 0; b < h; b++) {
			int xPos = x + a;
			int yPos = y + b;
			image[xPos + yPos * width] = data[offset + a + b * w];
		}
	}

	@Override
	public void setProperties(Hashtable<?, ?> arg0) {
	}

	public void reset() {
		ready = false;
		image = null;
	}
}
